Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delimiting Mata code with mata: ... end vs. mata { ... }

    Dear Matalisters,

    When writing Mata code in a do-file, are there important differences between the following two ways of delimiting the Mata content?

    Method 1: mata: ... end
    Code:
    mata :
      a
      b
    end
    Method 2: mata { ... }

    Code:
    mata {
      a
      b
    }
    Method 2 can be included in loops and Stata programs, are there any downsides?

    Thanks,
    BL

  • #2
    In case others come across this in the future, I have been using Method 2 extensively (intensively? both?) for the last 6 months in loops and ado-files and have not noticed any ill effects.

    Comment


    • #3
      I have found an instance in do-files in which mata { ... } and mata : ... end behave differently: mata { ... } seems not to like mata describe statements. An illustrative example, assuming X is an object currently defined in Mata:

      Code:
      mata {
        mata describe X
      }
      returns an error, while
      Code:
      mata :
        mata describe X
      end
      performs as expected.

      Comment

      Working...
      X